<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('memberpoint.integral/edit')}">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Integral')}:</label>
        <div class="col-xs-12 col-sm-4">
            <input id="c-integral" data-rule="required" min="0" class="form-control" name="row[integral]" type="number"
                   oninput="value=value.replace(/[^\d]/g, '').replace(/^0{1,}/g,'')"
                   value="{$row.integral|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Integral_use')}:</label>
        <div class="col-xs-12 col-sm-4">
            <input id="c-integral_use" class="form-control" name="row[integral_use]" type="number"
                   oninput="value=value.replace(/[^\d]/g, '').replace(/^0{1,}/g,'')"
                   value="{$row.integral_use}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">积分充值规则:</label>
        <div class="col-xs-12 col-sm-4">
            <div class="recharge-items">
                {foreach name="row.recharge_rules" id="vs"}
                <div class="input-group recharge-item fixmore-input-group" style="margin-top:5px">
                    <span class="input-group-addon">充</span>
                    <input type="text" class="form-control" name="row[enough][]" value="{$vs['enough']}">
                    <span class="input-group-addon">赠送会员</span>
                    <span class="input-group-select">
									<select name="row[level][]" class="form-control">
									    <option value="">请选择会员</option>
                                     	{foreach  name="levelList" id="vss"}
									        <option value="{$vss['id']}" {if $vss['id']==$vs['level']}selected{/if}>{$vss['name']}</option>
                                        {/foreach}
                                    </select>
								</span>
                    <div class="input-group-btn">
                        <button class="btn btn-danger" type="button" onclick="removeRechargeItem(this)"><i class="fa fa-remove"></i></button>
                    </div>
                </div>
                {/foreach}
            </div>
            <div style="margin-top:5px">
                <button type="button" class="btn btn-default" onclick="addRechargeItem()" style="margin-bottom:5px"><i class="fa fa-plus"></i> 增加优惠项</button>
            </div>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script language='javascript'>

    function addRechargeItem(){
        var html= '<div class="input-group recharge-item fixmore-input-group"  style="margin-top:5px">';
        html+='<span class="input-group-addon">充</span>';
        html+='<input type="text" class="form-control" name="row[enough][]"  />';
        html+='<span class="input-group-addon">赠送会员</span>';
        html+='<span class="input-group-select">';
        html+='<select name="row[level][]" class="form-control">';
        html+='<option value="">请选择会员</option>';
        html+='{foreach name="levelList" id="vs "}';
        html+='<option value="'+{$vs['id']}+'">'+"{$vs['name']}"+'</option>';
        html+='{/foreach}';
        html+='</select>';
        html+='</span>';
        html+='<div class="input-group-btn"><button type="button" class="btn btn-danger" onclick="removeRechargeItem(this)"><i class="fa fa-remove"></i></button></div>';
        html+='</div>';
        $('.recharge-items').append(html);
    }
    function removeRechargeItem(obj){
        $(obj).closest('.recharge-item').remove();
    }


</script>
